package cn.kxm.service.impl;

import java.util.Date;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.kxm.dao.InquiryBillDao;
import cn.kxm.dao.InquirybillMapper;
import cn.kxm.pojo.InquiryBill;
import cn.kxm.pojo.InquiryBillDetaill;
import cn.kxm.service.InquiryBillService;
@Service
public class InquiryBillServiceImpl implements InquiryBillService{

	@Autowired
	private InquiryBillDao inquiryBillDao;
	@Autowired
	private InquirybillMapper ib;
	@Override
	public List<Map<String, Object>> getInquirybill(InquiryBill iBill,Date endTime,Integer currentPageNo,
			Integer pageSize) {
		return inquiryBillDao.getInquirybill(iBill, endTime, (currentPageNo-1)*pageSize, pageSize);
	}
	@Override
	public int getInquirybillCount(InquiryBill iBill, Date endTime) {
		return inquiryBillDao.getInquirybillCount(iBill, endTime);
	}
	

	@Override
	public List<InquiryBill> findAllInquirybill(String code, String start,
			String end, String name, Integer page, Integer size) {
		// TODO Auto-generated method stub
		return ib.findAllInquirybill(code, start, end, name, page, size);
	}

	@Override
	public int getCount(String code, String start, String end, String name) {
		// TODO Auto-generated method stub
		return ib.getCount(code, start, end, name);
	}

	@Override
	public List<Map<String, String>> findDetailByBillCode(String code) {
		// TODO Auto-generated method stub
		return ib.findDetailByBillCode(code);
	}

	@Override
	public int addInquiry(InquiryBill i) {
		// TODO Auto-generated method stub
		return ib.addInquiry(i);
	}

	@Override
	public int addInquiryDtail(InquiryBillDetaill ibd) {
		// TODO Auto-generated method stub
		return ib.addInquiryDtail(ibd);
	}

	@Override
	public InquiryBill findByCode(String code) {
		// TODO Auto-generated method stub
		return ib.findByCode(code);
	}

	@Override
	public int modiftyIquiryBill(InquiryBill i) {
		// TODO Auto-generated method stub
		return ib.modiftyIquiryBill(i);
	}

	@Override
	public int modiftyIquiryBillDetal(String partCode, Integer amount,
			Double price, String memo) {
		// TODO Auto-generated method stub
		return ib.modiftyIquiryBillDetal(partCode, amount, price, memo);
	}

	@Override
	public int deletinquirybilldetaill(String code) {
		// TODO Auto-generated method stub
		return ib.deletinquirybilldetaill(code);
	}

	@Override
	public int deletinquirybill(String code) {
		// TODO Auto-generated method stub
		return ib.deletinquirybill(code);
	}

	@Override
	public String shenhe(String code) {
		// TODO Auto-generated method stub
		if (ib.shenhe(code) >= 1) {

			return "success";
		}

		return "errer";
	}

	@Override
	public String chexiaoService(String code) {
		// TODO Auto-generated method stub
		// TODO Auto-generated method stub
		if (ib.chexiao(code) >= 1) {

			return "success";
		}

		   return "errer";
	}

	@Override
	public String isdelService(String code) {
		// TODO Auto-generated method stub
	
		InquiryBill  ib2=	ib.findByCode(code);
		System.out.println(ib2.getCheckStatus()+"审核状态");
		   if(ib2.getCheckStatus()==2){
			   return "已审核";			   
		    }	
		      return "未审核"  ;
	}

	@Override
	public String saveExitService(String code) {
		// TODO Auto-generated method stub
	  InquiryBill  ib2=ib.findByCode(code);
		     if(ib2!=null){
		    	return "cun";		    	
		       }
		     return  "bucun";
	 }
	

}
